{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Remove Vowels from a String"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: removeVowels"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #删去字符串中的元音"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个字符串 <code>s</code>&nbsp;，请你删去其中的所有元音字母&nbsp;<code>'a'</code>，<code>'e'</code>，<code>'i'</code>，<code>'o'</code>，<code>'u'</code>，并返回这个新字符串。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"leetcodeisacommunityforcoders\"\n",
    "<strong>输出：</strong>\"ltcdscmmntyfrcdrs\"\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"aeiou\"\n",
    "<strong>输出：</strong>\"\"\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= S.length &lt;= 1000</code></li>\n",
    "\t<li><code>s</code>&nbsp;仅由小写英文字母组成</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [remove-vowels-from-a-string](https://leetcode.cn/problems/remove-vowels-from-a-string/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [remove-vowels-from-a-string](https://leetcode.cn/problems/remove-vowels-from-a-string/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"leetcodeisacommunityforcoders\"', '\"aeiou\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        stack=[]\n",
    "        for i in s:\n",
    "            if i not in [\"a\",\"e\",\"i\",\"o\",\"u\"]:\n",
    "                stack.append(i)\n",
    "        return \"\".join(stack)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        dct = set(\"aeiou\")\n",
    "        return \"\".join(w for w in s if w not in dct)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        rst = []\n",
    "        for letter in s:\n",
    "            if letter not in ['a','e','i','o','u']:\n",
    "                rst.append(letter)\n",
    "        return ''.join(rst)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        VOWEL_SET = set('aeiou')\n",
    "        return ''.join(char for char in s if char not in VOWEL_SET)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        words = ['a','e','i','o','u']\n",
    "        ans = \"\"\n",
    "        for i in range(len(s)):\n",
    "            if s[i] not in words:\n",
    "                ans += s[i]\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        \n",
    "        res = \"\"\n",
    "        for letter in s:\n",
    "            if letter not in \"aeiou\":\n",
    "                res += letter\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, S: str) -> str:\n",
    "        return S.replace('a','').replace('e','').replace('i','').replace('o','').replace('u','')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        return ''.join([x for x in s if x not in 'aeiou'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        vowel = ['a', 'e', 'i', 'o', 'u']\n",
    "        def is_vowel(ch):\n",
    "            return ch not in vowel\n",
    "        s_list = list(s)\n",
    "        s_filtered = filter(is_vowel, s_list)\n",
    "        return ''.join(s_filtered)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        my_str=['a','e','i','o','u']\n",
    "        for i  in s:\n",
    "            if i in my_str:\n",
    "                s=s.replace(i,'')#请注意，replace函数返回一个新的字符串，不会对原字符串修改\n",
    "        return s        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        ans = \"\"\n",
    "        for i in s:\n",
    "            if i not in [\"a\",\"e\",\"i\",\"o\",\"u\"]:\n",
    "                ans += i\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        res = []\n",
    "        for i in s:\n",
    "            if i not in ['a', 'e', 'i', 'o', 'u']:\n",
    "                res.append(i)\n",
    "\n",
    "        return ''.join(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        arr = ('a', 'e', 'i', 'o', 'u')\n",
    "        res = \"\"\n",
    "        for i in s:\n",
    "            if i.lower() not in arr:\n",
    "                res += i\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        a=list(s)\n",
    "        for j in ['a','e','i','o','u']:\n",
    "            while j in a:\n",
    "                a.remove(j)\n",
    "        return ''.join(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "VOWEL_SET = set('aeiou')\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        return ''.join(char  for char in s if char not in VOWEL_SET)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        ans = \"\"\n",
    "        for i in s:\n",
    "            if i not in set([\"a\",\"e\",\"i\",\"o\",\"u\"]):\n",
    "                ans += i\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        stack = []\n",
    "        for ch in s:\n",
    "            if ch not in {\"a\", \"e\", \"i\", \"o\", \"u\"}:\n",
    "                stack.append(ch)\n",
    "        return \"\".join(stack)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        ret=\"\"\n",
    "        yuan=['a','e','i','o','u']\n",
    "        for ch in s:\n",
    "            if ch not in yuan:\n",
    "                ret+=ch\n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        s1 = ''\n",
    "        for i in s:\n",
    "            if i not in ['a','e','i','o','u']:\n",
    "                s1+=i\n",
    "        return s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        return s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        target = ['a', 'e', 'i', 'o', 'u']\n",
    "        res=[]\n",
    "        for c in s:\n",
    "            if c not in target:\n",
    "                \n",
    "                res.append(c)\n",
    "        return ''.join(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        r = ''\n",
    "        for c in s:\n",
    "            if c in 'aeiou':\n",
    "                continue\n",
    "            r += c\n",
    "        return r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        stack = []\n",
    "        for ch in s:\n",
    "            if ch not in {\"a\", \"e\", \"i\", \"o\", \"u\"}:\n",
    "                stack.append(ch)\n",
    "        return \"\".join(stack)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        ans = ''\n",
    "        for ch in s:\n",
    "            if ch in 'aeiou':\n",
    "                continue\n",
    "            ans += ch\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        res = ''\n",
    "        for i in s:\n",
    "            if i not in ['a','e','i','o','u']:\n",
    "                res += i\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        res = ''\n",
    "        for i in s:\n",
    "            if i not in ['a','e','i','o','u']:\n",
    "                res += i\n",
    "        return res\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "\n",
    "\n",
    "        set_s = set([\"a\",\"e\",\"i\",\"o\",\"u\"])\n",
    "\n",
    "        res = \"\"\n",
    "\n",
    "        for i in s:\n",
    "\n",
    "            if not i in set_s:\n",
    "\n",
    "                res += i\n",
    "\n",
    "        \n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def removeVowels(self, s: str) -> str:\n",
    "        sty = ['a', 'e', 'i', 'o', 'u']\n",
    "        new =''\n",
    "        for i in s:\n",
    "            if i in sty:\n",
    "                continue\n",
    "            else:\n",
    "                new += i\n",
    "        return new"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
